﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web;
using System.IO;
using System.Web.Security;
using logistical.Models;
using common;

namespace logistical.Controllers
{
    public class indexController : baseController
    {
        [HttpGet, AllowAnonymous]
        public object helloworld()
        {
            return new { msg = "helloworld" };
        }

        [HttpGet]
        public object PCMenu()
        {
            UserInfo uo = CurUser.get();
            var o = new logisticalEntities();
            var p = o.sys_menu.Where(x => x.code.Contains("PC") || x.code == "01")
                .Join(o.sys_menuRole.Where(x => x.roleid == uo.role), a => a.id, b => b.menuid, (a, b) => new
                {
                    a.id,
                    a.code,
                    a.name,
                    a.icon,
                    a.url,
                    a.pid,
                    b.btns
                }).OrderBy(x => x.code);
            return new { msg = "seccuss!", data = p, user = uo };
        }

        [HttpGet]
        public object MobileMenu()
        {
            UserInfo uo = CurUser.get();
            var o = new logisticalEntities();
            var p = o.sys_menu.Where(x => x.code.Contains("Mobile") || x.code == "02")
            .Join(o.sys_menuRole.Where(x => x.roleid == uo.role), a => a.id, b => b.menuid, (a, b) => new
                {
                    a.id,
                    a.code,
                    a.name,
                    a.icon,
                    a.url,
                    a.pid,
                    b.btns
                }).OrderBy(x => x.code);
            return new { msg = "seccuss!", data = p, user = uo };
        }
    }
}
